#! /bin/bash
export LANG=en_US.UTF-8

CURSTR=$(ps aux | grep "$1 " | grep -v grep)
curStr=$(echo $CURSTR | awk '{cc=index($0,"redis-server");if(cc>-1){print substr($0,cc);}}')
UW=$(echo $curStr| grep ":")

if [[ "$UW" != "" ]];then
        PORT=$(ps aux | grep -v grep | grep -v ps.sh|grep redis-server | grep $1 | awk -F ':' '{print $(NF)}')
        echo "tcp        0      0 :::$PORT"
else
        netstat -lnp | grep $1/ | grep tcp | grep LISTEN
fi